package com.pearadmin.modules.sys.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.pearadmin.common.web.domain.request.PageDomain;
import com.pearadmin.modules.sys.domain.WorkCar;
import com.pearadmin.modules.sys.mapper.WorkCarMapper;
import com.pearadmin.modules.sys.service.IWorkCarService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 车队工作记录Service业务层处理
 *
 * @author Mr.Ling
 * @date 2021-11-26
 */
@Service
public class WorkCarServiceImpl implements IWorkCarService {
    @Autowired
    private WorkCarMapper workCarMapper;

    /**
     * 查询车队工作记录
     *
     * @param id 车队工作记录ID
     * @return 车队工作记录
     */
    @Override
    public WorkCar selectWorkCarById(String id) {
        return workCarMapper.selectWorkCarById(id);
    }

    /**
     * 查询车队工作记录列表
     *
     * @param workCar 车队工作记录
     * @return 车队工作记录
     */
    @Override
    public List<WorkCar> selectWorkCarList(WorkCar workCar) {
        return workCarMapper.selectWorkCarList(workCar);
    }

    /**
     * 查询车队工作记录
     * @param workCar 车队工作记录
     * @param pageDomain
     * @return 车队工作记录 分页集合
     * */
    @Override
    public PageInfo<WorkCar> selectWorkCarPage(WorkCar workCar, PageDomain pageDomain) {
        PageHelper.startPage(pageDomain.getPage(), pageDomain.getLimit());
        List<WorkCar> data = workCarMapper.selectWorkCarList(workCar);
        return new PageInfo<>(data);
    }

    /**
     * 新增车队工作记录
     *
     * @param workCar 车队工作记录
     * @return 结果
     */

    @Override
    public int insertWorkCar(WorkCar workCar) {
        return workCarMapper.insertWorkCar(workCar);
    }

    /**
     * 修改车队工作记录
     *
     * @param workCar 车队工作记录
     * @return 结果
     */
    @Override
    public int updateWorkCar(WorkCar workCar) {
        return workCarMapper.updateWorkCar(workCar);
    }

    /**
     * 删除车队工作记录对象
     *
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteWorkCarByIds(String[] ids) {
        return workCarMapper.deleteWorkCarByIds(ids);
    }

    /**
     * 删除车队工作记录信息
     *
     * @param id 车队工作记录ID
     * @return 结果
     */
    @Override
    public int deleteWorkCarById(String id) {
        return workCarMapper.deleteWorkCarById(id);
    }

    @Override
    public List<WorkCar> getByOrderId(String orderId) {
        return workCarMapper.getByOrderId(orderId);
    }

    @Override
    public String selectAnodeCodeByOrderId(String orderId) {
        return workCarMapper.selectAnodeCodeByOrderId(orderId);
    }

}
